<?php
require 'function.php';
require 'db.php';
//SQL
//create table news(cid int primary key auto_increment,title varchar(100),content text ,addtime int,click int)charset utf8;

//文章模块
$action = isset($_GET['a'])?$_GET['a']:'index';
switch ($action) {
	case 'index':
		$data = select('select * from news n JOIN category c on n.cid = c.id order by addtime DESC');
		include 'view/news.index.html';
		break;
	case 'add':
		$categorys = select("select * from category");
		$categorys = categoryTree($categorys);
		// echo 'ok';exit;
		include 'view/news.add.html';
		break;
	case 'doadd':
	$title =$_POST['title'];
	$content =$_POST['content'];
	$addtime =time();
	$cid = $_POST['cid'];
	$click=100;
	// echo $_POST['cid'];exit;
	execute("INSERT INTO news (title,content,addtime,click,cid)
		VALUES('$title','$content',$addtime,$click,$cid)");
		header('location:news.php');
	default:
		
		break;








}







